<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>用户名字：{{username}}</p>
        <!-- 会双向绑定 -->
        <!-- 
            可以和input、textarea、select、
         -->
        <input type="text" v-model="username">
        <!-- 不会双向绑定 -->
        <!-- 
            v-bind是单项绑定，
            v-model是双向绑定
         -->
        <input type="text" :value="username">

        <hr/>
        <select v-model="city">
            <option value="1">北京</option>
            <option value="2">上海</option>
            <option value="3">杭州</option>
        </select>

        <hr/>
        <div>
            <input type="text" v-model.number="n1"> + <input v-model.number="n2" type="text"> = {{n1 + n2}}
        </div>
        <hr>
        <div>

            <input type="text" v-model.trim="username"><br>
            <input type="button" value="测试" @click="btn">
        </div>
        <hr>
        <div>
            非实时更新：
            <input v-model.lazy="username" type="text">
        </div>

    </div>
    <script src="./lib/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                username: "zhangshan",
                city: '1',
                n1: 1,
                n2: 2,
            },
            methods: {
                btn() {
                    console.log('输入框里输入的值："' + this.username + '"')

                }
            }
        })
    </script>
</body>

</html>